import { createRouter, createWebHashHistory } from "vue-router";

import Layout from "@/views/Layout/index"; // 可以用 @/views/Layout/  默认找index

const routes = [
  {
    path: "/",
    name: "Home",
    redirect: "index",
    hidden: false,
    meta: {
      name: "首页",
    },
  },

  {
    path: "/login",
    name: "Login",
    hidden: false,
    meta: {
      name: "登录",
    },
    component: () => import("../views/login/index.vue"),
  },
  {
    path: "/console",
    name: "Console",
    redirect: "index",
    meta: {
      name: "主页",
      icon: "console",
    },
    hidden: true,
    component: Layout,
    children: [
      {
        path: "/index",
        name: "Index",
        meta: {
          name: "主页",
          icon: "console",
        },
        component: () => import("../views/Console/index.vue"),
      },
    ],
  },
  {
    path: "/Function",
    name: "Function",
    meta: {
      name: "工具箱",
      icon: "info",
    },
    hidden: true,
    component: Layout,
    children: [
      {
        path: "/Function/material",
        name: "material",
        hidden: true,
        meta: {
          name: "原料管理"
        },
        component: () => import("../views/Function/Material/Material")
      },
      {
        path: "/Function/Agri",
        name: "Agri",
        hidden: true,
        meta: {
          name: "农产品管理",
          icon: "info",
        },
        component: () => import("../views/Function/CropsManage.vue"),
      },
      {
        path: "/Function/cropDetail/:cropId",
        name: "cropDetail",
        hidden: false,
        meta: {
          name: "过程详情"
        },
        component: () => import("../views/Function/CropsProcess.vue")
      },
      {
        path: "/Function/process",
        name: "process",
        hidden: true,
        meta: {
          name: "加工管理"
        },
        component: () => import("../views/Function/Process/Process")
      },
      {
        path: "/Function/processDetail/:productId",
        name: "processDetail",
        hidden: false,
        meta: {
          name: "加工过程"
        },
        component: () => import("../views/Function/Process/ProcessDetail")
      },
      {
        path: "/Function/sales",
        name: "sales",
        hidden: true,
        meta: {
          name: "零售管理"
        },
        component: () => import("../views/Function/Sales/Sales")
      },
      {
        path: "/Function/search",
        name: "search",
        hidden: true,
        meta: {
          name: "溯源系统"
        },
        component: () => import("../views/Function/Search")
      },
    ],
  },
  {
    path: "/User",
    name: "User",
    meta: {
      name: "个人中心",
      icon: "user",
    },

    hidden: true,
    component: Layout,
    children: [
      {
        path: "/User/signUp",
        name: "SignUp",
        hidden: true,
        meta: {
          name: "身份注册",
        },
        component: () => import("../views/User/identity.vue"),
      },
      {
        path: "/User/checkSignUp",
        name: "CheckSignUpy",
        hidden: true,
        meta: {
          name: "审核注册",
        },
        component: () => import("../views/User/checkSignUp.vue"),
      },
    ],
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export default router;
